package com.lanou3g.k12.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lanou3g.k12.entity.Section;
import com.lanou3g.k12.mapper.SectionMapper;
import com.lanou3g.k12.service.SectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class SectionServiceImpl implements SectionService {
    @Autowired
    private SectionMapper sectionMapper;


    @Override
    public List<Section> search(Integer page, String keyword, Integer size, Long cpId) {
        List<Section> sectionList = sectionMapper.search("%"+keyword+"%",cpId);
        return sectionList;
    }

    @Override
    public List<Section>findAllSection(Integer page, Integer size, Long cpId) {
        List<Section> sectionList =sectionMapper.findAllSection(cpId);
        return sectionList;
    }

    @Override
    public void deleteSomeSection(Long[] ids) {
        sectionMapper.deleteSomeSection(ids);

    }

    @Override
    public void deleteOneSection(Long id) {
        sectionMapper.deleteOneSection(id);
    }

    @Override
    public void insertSection(Section section) {
        Date date = new Date();
        section.setCreateTime(date);
        section.setUpdateTime(date);
        sectionMapper.insertSection(section);
    }

    @Override
    public void updateSection(Long id, Section section) {
        Date date = new Date();
        section.setUpdateTime(date);
        sectionMapper.updateSection(id,section);
    }
}
